package com.ms.p2p.template.method;

import com.ms.common.utils.AppContext;
import com.ms.p2p.Constants;
import com.ms.p2p.utils.TradeUtil;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by xing_ on 2017/5/23.
 * 创建一个token
 */
@Repository
public class TokenMethod implements TemplateMethodModelEx {



    @Override
    public Object exec(List arguments) throws TemplateModelException {
            String token  ="token_"+TradeUtil.getTrano();
            AppContext.setSessionAttr(Constants.VALIDATE_TOKEN_KEY,token);
            return new SimpleScalar(token);
    }
}
